/**
***********************************************************************************************************
* 
***********************************************************************************************************
* @file RBD3D9PixelBuffer.h
***********************************************************************************************************/

#ifndef __RBD3D9PIXELBUFFER_H__
#define __RBD3D9PIXELBUFFER_H__

#ifdef  HEADER_ONCE
#pragma HEADER_ONCE
#endif

#ifdef  HEADER_MSG
#pragma HEADER_MSG(RBD3D9PixelBuffer.h)
#endif

/***********************************************************************************************************
* Includes
***********************************************************************************************************/
#include <RBMain/RBPixelBuffer.h>

/***********************************************************************************************************
* Forward declarations
***********************************************************************************************************/
struct IDirect3DSurface9;
class RBD3D9Renderer;

/***********************************************************************************************************
* Classes
***********************************************************************************************************/

class RBD3D9PixelBuffer : public RBPixelBuffer
{
    RBDeclareRTTI(RBD3D9PixelBuffer, RBPixelBuffer);
public:
                            RBD3D9PixelBuffer   (uint32 uiUsage, uint32 uiMemPoolMask, RBHardwareBufferManager* pCreator, uint32 uiWidth, uint32 uiHeight, RBPixelFormat eFormat, 
                                                 uint32 uiMSAA, RBTexture* pContainer, bool bCreateSurface = true);

                           ~RBD3D9PixelBuffer   ();

    IDirect3DSurface9*      GetSurface          () const { return m_pD3DSurface; }

    virtual void            OnReset             (bool bBeforeReset);

    void                    CreateSurface       ();

    virtual void            Resize              (uint32 uiWidth, uint32 uiHeight);

    virtual void            Blit                (RBPixelBuffer* pDest, float2 srcStart = float2(0,0), float2 srcEnd = float2(1,1),
                                                 float2 dstStart = float2(0,0), float2 dstEnd = float2(1,1)) const;

    virtual MappedBuffer     Map                (MapType eMapType);
    virtual void             Unmap              () ;

protected:

private:
    friend class RBD3D9Texture;
    friend class RBD3D9Renderer;

    void                    SetSurface          (IDirect3DSurface9* pD3DSurface);

private:
    
    bool                m_bOwned;
    IDirect3DSurface9*  m_pD3DSurface;
};

/***********************************************************************************************************/

#endif // __RBD3D9PIXELBUFFER_H__
